home *** CD-ROM | disk | FTP | other *** search
/ MacSilverWare / macsilverware.iso / Education / Bugglings / Buggling Docs.text < prev    next >
Text File  |  1989-05-19  |  18KB  |  413 lines

  1. Bugglings 1.0, by Chuck Shotton
  2. ===============================
  3.  
  4. (Note: This documentation looks best if printed using Monaco 9 pt,
  5.        with tabs every 3 spaces)
  6.              
  7. (Another Note: This is a reasonably complicated program. You'll get
  8.        more out of it if you carefully study the documentation prior
  9.              to running Bugglings.)
  10.  
  11. ============
  12. Introduction
  13. ============
  14. If you ever wanted to be the master of your own universe, here's the
  15. program for you...
  16.  
  17. Bugglings is a program based on the Computer Recreations column in the
  18. May 1989 issue of Scientific American. This program simulates life in
  19. a test tube, with tiny bugs swimming around, feeding on food particles.
  20.  
  21. The bugs are driven by a set of 9 genes that determine how
  22. they swim about in the test tube. As the bugs feed on food particles,
  23. grow fat and fission into new bugs. When this happens, the two new bugs
  24. retain most of the genetic features of the parent bug, but one of them
  25. is slightly mutated.
  26.  
  27. Through the course of several generations, bugs will evolve survival
  28. traits based on their environment. Some bugs will "learn" where food
  29. shows up, moving in those areas only. Some evolve into bugs that can 
  30. rapidly cover large distances, searching for food. Others will evolve 
  31. into carnivores that feed on their weaker neighbors. You can affect 
  32. the evolution of your bugs by modifying their environment while the 
  33. simulation is running.
  34.  
  35. ===================
  36. Running the Program
  37. ===================
  38. The Stuffit archive contains two versions of the Bugglings program. The
  39. version titled "Bugglings" should run on any Macintosh that has 512k to
  40. spare (I'm not sure if it'll run on 512k Macs or not). The program
  41. titled "Bugglings '020+" will only work on Macs with a 68020 or greater
  42. and a math coprocessor. Other than the different processor requirements,
  43. both programs are identical, including support for color. Bugglings is
  44. compatible with Multifinder, and will run simulations in the background.
  45.  
  46. To get started, simply run the appropriate version of Bugglings for your
  47. Mac. For monochrome display users, double-clicking on the "Black & White
  48. Startup" document will bring Bugglings up already configured for your 
  49. display.
  50.  
  51. =============
  52. The Test Tube
  53. =============
  54. The main window that opens up represents the test tube you will be
  55. experimenting in. The screen is arranged in a rectangular matrix that 
  56. can vary in size from 8 by 15 cells to 275 by 500 cells. Each location
  57. on the screen can contain a food particle, a bug, a piece of the test
  58. tube wall, or can be empty. Bugs are represented by solid (black, white,
  59. or colored) boxes, while food is represented by grey boxes.
  60.  
  61. The bottom of the main window contains two rectangular boxes. The box on
  62. the lower left will display the number of generations (cycles) that 
  63. have elapsed in the simulation, as well as the current living population
  64. total in the test tube. The wider box in the lower right of the screen
  65. is the status box, and will be used to display information about a 
  66. specific bug.
  67.  
  68. ========
  69. The Bugs
  70. ========
  71. As mentioned, the bugs have 9 genes that control their behavior. 8 of 
  72. the genes control the bugs' motion, while the 9th controls how 
  73. carnivorous a bug is. In addition to these genes, all bugs have
  74. attributes that control:
  75. • How old they must be before they can breed. 
  76. • How much energy (food) they must have in order to breed.
  77. • How much energy (food) they can hold at one time. (stomach size?)
  78. • How weak they can be before they die.
  79. • Who their parent was.
  80.  
  81. During each cycle, a bug may turn and move in one of eight directions as
  82. shown below:
  83.        
  84.           Forward
  85.       Left   |   Right
  86.            \ | /
  87. Med. Left----+----Med. Right
  88.            / | \
  89.   Hard Left  |  Hard Right
  90.             Reverse
  91.  
  92. The direction of motion is relative to the direction a bug is facing. If
  93. a bug is facing the right side of the screen and decides to move to the
  94. right (Med. Right), the bug will appear to move towards the bottom of 
  95. the screen. The bug's new facing direction would then become towards the
  96. bottom of the screen, and subsequent moves would be relative to that
  97. facing. 
  98.  
  99. Each move costs a bug 1 point of energy. When a bug moves across a food
  100. particle, it is eaten. If the bug's total energy is below its maximum,
  101. the the energy value of the food particle is added to the bug's total
  102. energy. If a bug eats another bug, its energy is increased by the amount
  103. of energy the eaten bug had. If a bug's energy level falls to 0, it will
  104. be unable to move.
  105.  
  106. The Genes
  107. ---------
  108. The eight movement genes determine the probability that a bug will turn
  109. and move in a given direction. The first gene listed is a bug's tendency
  110. to move straight ahead. The second is its tendency to make right turns, 
  111. and so forth (clockwise around the diagram above, ending with the 8th
  112. gene controlling left turns.) If a bug had the following genes:
  113. 10,5,0,0,5,0,0,0
  114. its movement is computed as follows.The value of all genes is totaled up.
  115. In this case the total value of all genes is 20. The probability that a bug
  116. will turn and move in any direction is computed by dividing the value of
  117. a single gene by the total. In this case, the bug will move forward 50% of
  118. the time (10/20) and will go to the right or in reverse 25% of the time
  119. respectively. A random number is chosen, and according to the distribution
  120. of probabilities, the appropriate direction for the bug is chosen.
  121.  
  122. The 9th gene controls a bug's taste for flesh. If the Carnivore gene falls
  123. below a user-specified level, the bug will only eat food particles. If the
  124. gene is above another level, the bug will only eat other bugs. If it falls
  125. in the range between these two levels, it represents the probability that
  126. a bug will choose to eat food or other bugs. The higher the gene's value,
  127. the less herbivorous the bug and vice versa. Bugs will only feed on other
  128. bugs with a lower Carnivore gene, so this gene also represents how
  129. physically strong a bug is.
  130.  
  131. Breeding
  132. --------
  133. A bug will breed provided it is old enough and has enough energy stored up.
  134. When a bug breeds, its offspring have a chance of having mutated genes. It
  135. is through this mutation process that new bugs evolve. Also, you have the
  136. option of introducing radiation into the environment which will cause
  137. mutations in bugs at any time, not just when breeding.
  138.  
  139. Breeding is by fission. When this occurs, both new bugs will have half
  140. of the energy of the original bug, and their age will be reset to zero.
  141. Also, the new bug will have some of its genes mutated. The original bug,
  142. now half its original size, will remain untouched genetically. There is
  143. a limit of 1000 bugs total in the simulation at any one time.
  144.  
  145. ==========
  146. The Cursor
  147. ==========
  148. You will notice that the cursor changes from the usual arrow to a set of
  149. crosshairs when the mouse enters the test tube area of the main screen.
  150. By positioning the cursor over a bug while the simulation is running (or
  151. paused) and clicking, the stats of a particular bug will be shown in the
  152. status box. If you hold down the shift key and click on a bug, that bug
  153. will be destroyed and removed from the test tube.
  154.  
  155. ==============
  156. The Status Box
  157. ==============
  158. The status box will show the stats for whatever bug is currently selected
  159. using the cursor as described above. If that bug dies, the display will
  160. show no bug. A sample display in the status box might contain:
  161.  
  162. #22(5):M=90 E=390 D=6 Genes: 0,5,0,2,0,3,2,1,3
  163.  
  164. The fields are interpreted as follows:
  165.  
  166. #22(5) - This indicates that the bug being observed is #22, and it belongs 
  167. to the family of bugs whose original parent was bug 5. For users with
  168. color displays, all bugs of the same family have the same color. If there
  169. are more than 7 bugs initially, then some colors will be used by more than
  170. one family.
  171.  
  172. M=90 - This shows that the bug has moved 90 times, or is 90 cycles old.
  173.  
  174. E=390 - This is the bug's current energy level.
  175.  
  176. D=6 - This is absolute direction that a bug is facing. In this case, 6
  177. indicates that the bug is facing to the left of the screen. (0 is up,
  178. 2 is right, etc.)
  179.  
  180. Genes: - These nine numbers are the nine genes associated with each bug.
  181. The first number is the Forward gene, followed by the Right gene, etc. The
  182. last gene is the Carnivore gene.
  183.  
  184. Tracking Bugs
  185. -------------
  186. When you are tracking a bug, it is often difficult to pick your bug out
  187. of a crowd. By clicking the mouse in the Status Box, all motion on the
  188. screen will stop, and the currently selected bug will flash briefly.
  189.  
  190. =========
  191. The Menus
  192. =========
  193. Bugglings only has three menus. The FILE menu is used to load or save
  194. the current configuration of the test tube and bugs. EDIT menu options
  195. are only functional when used with desk accessories. The SIMULATION menu
  196. contains all of the controls that are used to run and modify the
  197. simulation.
  198.  
  199. FILE
  200. ----
  201. The Open command is used to load a settings file. These files contain
  202. saved values for all of the information provided in the Environment, Bug,
  203. and Test Tube settings dialogs.
  204.  
  205. The Save As command will save the current values of the information in the
  206. Environment, Bug, and Test Tube settings dialogs.
  207.  
  208. Quit will exit the program immediately. Clicking in the go-away box of the
  209. main window has the same effect.
  210.  
  211. EDIT
  212. ----
  213. As mentioned, options in the Edit menu are supplied for the convenience of
  214. Desc Accessories running under the regular Finder.
  215.  
  216. SIMULATION
  217. ----------
  218. The Run, Pause, and Stop commands are used to control the execution of a
  219. simulation. When Run is selected, a new simulation is started, using the
  220. current settings from the various dialogs.
  221.  
  222. Pause will cause the currently executing simulation to halt. This makes it
  223. easier to select bugs for tracking, change environment settings, or get
  224. a sandwich. Selecting Pause again will resume the current simulation.
  225.  
  226. Stop will terminate the simulation, leaving the screen undisturbed. If
  227. the population reaches zero during any simulation, the simulation will
  228. automatically stop.
  229.  
  230. The Environment, Bug, and Test Tube Settings options bring up dialogs for
  231. controlling the simulation. These dialogs are described in more detail
  232. below.
  233.  
  234. The Change Colors option will temporarily invert the display. This option
  235. can be used to determine which background color (white or black) is more
  236. appealing. For black and white displays, it is suggested that a white 
  237. background always be used, since most bugs will appear black.
  238.  
  239. ================
  240. Settings Dialogs
  241. ================
  242.  
  243. Each field in the following dialogs is described. At the end of the 
  244. description is the legal range of values for that field.
  245.  
  246. Environement Settings
  247. ---------------------
  248. The Environment Settings Dialog is the most important dialog box. This
  249. dialog can be used to change the parameters of a simulation before it is
  250. started, or while the simulation is executing. This allows you to increase
  251. the food being added to the environment, for example, while the 
  252. simulation is running.
  253.  
  254. *** IMPORTANT NOTE ***
  255. Any changes to the Environment Settings will NOT take effect until you
  256. click on the OK button, or press return. This allows you to change many
  257. parameters at once while the simulation is running. If you decide you 
  258. don't want to change the values, clicking on cancel will revert to 
  259. the currently active values. If the value is out of range, the previous
  260. correct value will be supplied.
  261.  
  262. The fields in the Environment Settings dialog are defined as follows:
  263.  
  264. Radiation Level : This is a number between 0 and 100 that represents the
  265. percentage chance that one bug will be mutated during any cycle. The bug
  266. is chosen at random, as are the genes.
  267.  
  268. Herbivore Level : If a bug's Carnivore gene falls below this level, the
  269. bug will only eat food particles. Set it very  high if you want all
  270. bugs to be herbivores. 0-32767
  271.  
  272. Carnivore Level : If a bug's Carnivore gene is above this value, the bug
  273. will only feed on other bugs. Again, set this very high (and higher than
  274. the Herbivore Level) if you want only Herbivores. 0-32767
  275.  
  276. Food Value : When a bug eats a food particle, it will gain this much
  277. energy. 0-32767
  278.  
  279. Food Density : This field describes how dense food will be distributed
  280. when the simulation starts. It is specified as a 1 in N+1 chance that a 
  281. given cell will contain a food particle. If the value is 3, there will
  282. be food in 25% of the cells when the simulation starts. 1-1000
  283.  
  284. Feeding Frequency : This represents a percentage of cycles in which food
  285. will be added to the test tube. If it is 75, food will be added to the
  286. simulation 75% of the time (3 cycles out of 4). 0-100
  287.  
  288. Feeding Amount : When it's feeding time, this is how may food particles
  289. will be randomly placed in the test tube. (If an attempt is made to place 
  290. a particle on an occupied cell, the particle is discarded.) 0-32767
  291.  
  292. Full Energy Level: This is the maximum amount of energy a bug can hold.
  293. It's analogous to the bug's stomach size. 0-32767
  294.  
  295. Death Level : If a bug's energy level falls below this value, a bug will
  296. die and be removed from the simulation. -32768-32767
  297.  
  298. Breeding Age : A bug must survive this many cycles or generations before
  299. it is allowed to breed. 0-32767
  300.  
  301. Breeding Energy : A bug must possess this much energy in order to fission.
  302. Set this value above the Full Energy level to inhibit breeding. 0-32767
  303.  
  304. Bug Settings
  305. ------------
  306. This dialog can only be invoked prior to running a simulation. The fields
  307. are defined as follows:
  308.  
  309. Initial Bug Count : This represents how many bugs will be present
  310. in the test tube when the simulation starts. 1-1000
  311.  
  312. Initial Energy : All of the initial bugs will start with this much energy.
  313. 0-32767
  314.  
  315. Initial Genes : This determines the highest value for any gene in the
  316. initial bugs. Gene values will range from 0 to this value. The higher the
  317. value, the less impact mutations will have on the genes. Once the 
  318. simulation is running, the bugs' gene values may range from 0 to 2 times
  319. this value. 0-50
  320.  
  321. # Genes to Mutate : When a bug's genes mutate, due to radiation or
  322. breeding, this value determines how many genes are affected. 0-9
  323.  
  324. Mutation Delta : When a gene is mutated this value is used to determine
  325. the amount of mutation. A gene will be changed by a random amount 
  326. between -N and N. 0-50
  327.  
  328. Bug #1 is Special : This check box really doesn't do anything.
  329.  
  330. Looper : This check box, when selected, will initialize bug #1's 
  331. movement genes to 10,5,0,0,0,0,0,0, causing it to make large clockwise
  332. loops across the screen.
  333.  
  334. Carnivore : When this check box is selected, bug #1's Carnivore gene will
  335. be set high enough to insure that it will be a pure carnivore.
  336.  
  337. Test Tube Settings
  338. ------------------
  339. This dialog can only be invoked prior to running a simulation. It controls
  340. many of the parameters associated with the size and appearance of the
  341. display. Fields are as follows:
  342.  
  343. Garden of Eden : As described in the Scientific American article, this
  344. check box will cause food to be replenished at twice the normal rate in
  345. an area in the upper left corner of the screen.
  346.  
  347. Wrap-around Universe : When checked, this option will cause bugs that move
  348. off the edge of the screen to reappear on the opposite edge. Turning it off
  349. will draw a wall around the screen that the bugs will bang into.
  350.  
  351. Use White Background : This option is useful for monochrome displays. It
  352. causes the background to be white instead of the default black. The 
  353. bugs will then show up as black rectangles.
  354.  
  355. Cell Width : This determines how wide cells on the screen will be. The
  356. larger the width, the fewer horizontal cells available. 1-32
  357.  
  358. Cell Height : Same as above, but determines the vertical size of the cells.
  359. Width and Height need not be the same value. 1-32
  360.  
  361. ===============
  362. Hints and Stuff
  363. ===============
  364. Bugglings is a fairly complicated program. You can simulate lots of 
  365. natural population phenomena, ranging from locust plagues to coyote 
  366. and rabbit population cycles. Of course, it's all in your interpretation
  367. of the behavior in the test tube.
  368.  
  369. The program tends to bog down when the populations get very high. It's
  370. possible to limit population size by adjusting things like the Full
  371. Energy Level and Food Value (aside from the obvious parameters like
  372. Breeding Age and Energy). The evolution of well-adapted bugs seems to
  373. work best with high turn-over in population initially, and then making
  374. the population more stable later. Do this by raising the breeding age and
  375. energy while the simulation is running.
  376.  
  377. ======================================
  378. ShareWare, Source Code, Licenses, etc.
  379. ======================================
  380.  
  381. Bugglings was written by Chuck Shotton in Think Pascal. The program is
  382. copyrighted 1989 by Chuck Shotton and BIAP Systems. Portions of the
  383. program are Copyrighted by Think, Inc.
  384.  
  385. If you find Bugglings to be a useful or interesting program, please 
  386. consider paying the $5 ShareWare fee. This gives me incentive to write
  387. more goodies like this one. If you are truly interested in the inner
  388. workings of this program, or would like to make your own modifications,
  389. Think (Lightspeed) Pascal source code is available for $8. The source
  390. should also be an easy port to other Mac Pascal compilers.
  391.  
  392. Limited license is granted for your own personal use of this software.
  393. If you are considering bundling this software with other packages, adding
  394. it to a commercial shareware anthology, or using it in a commercial,
  395. government, or educational environment, please contact the author regarding
  396. special licensing agreements.
  397.  
  398. Thanks,
  399.  
  400. Chuck Shotton
  401. c/o BIAP Systems
  402. P.O. Box 580622
  403. Houston, TX 77258-0622
  404.  
  405. Genie: C.SHOTTON12
  406. Compu$erve: 72460,764
  407. AppleLink: D1683
  408.  
  409. BIAP BBS: (713) 480-7422, 1200-8-N-1
  410.  
  411.  
  412.  
  413.